package com.ylkj.wx.facade.impl;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;

import com.ylkj.wx.constant.WeiXBaseConstant;
import com.ylkj.wx.message.resp.BaseMessage;
import com.ylkj.wx.message.resp.TextMessage;
import com.ylkj.wx.utils.MessageUtil;

public class TestMain {

	public static void main(String[] args) {
		
		BaseMessage baseMessage = new BaseMessage();
		//开发者微信号
		baseMessage.setFromUserName("niechw");
		//接收方帐号（收到的OpenID）
		baseMessage.setToUserName("baoying");
		// TODO Auto-generated method stub
		//根据扫描或输入的doectorCloudCode后的响应
		TextMessage textMessage = new TextMessage();
		copyBaseMessageToSubMessage(textMessage, baseMessage);
		// 您扫描的二维码有问题，请询问医生重新获得二维码。
		textMessage.setContent("1、有咨询问题可以进入找律师页面，与律师进行咨询");
		textMessage.setCreateTime(System.currentTimeMillis());
		textMessage.setMsgType(WeiXBaseConstant.RESP_MESSAGE_TYPE_TEXT);
		String strResponse = MessageUtil.messageToXml(textMessage);
		System.out.println(strResponse);
	}
	
	//将父类的属性拷贝到子类
	private static void copyBaseMessageToSubMessage(Object subMessage, Object baseMessage){
		try {
			//基础内容copy
			BeanUtils.copyProperties(subMessage, baseMessage);
		} catch (IllegalAccessException e) {
		} catch (InvocationTargetException e) {
		}
	}
}
